﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Content;

namespace Tomahawk.Runtime.Canvas
{
    /// <summary>
    /// Define the required methods to implement your own canvas primitive rederers,
    /// like sprites, geometric shapes, etc.
    /// </summary>
    public interface ICanvasPrimitiveRenderer
    {
        /// <summary>
        /// Implement this method to provide a rendering mechanism for this primitives
        /// </summary>
        void Render();

        /// <summary>
        /// Implement this method to initialize the renderer
        /// </summary>
        void Initialize(GraphicsDevice graphicsDevice);

        /// <summary>
        /// Add a new primitive to the renderer
        /// </summary>
        void AddPrimitive(ICanvasPrimitive newPrimitive);

        /// <summary>
        /// Remove a primitive from the redenrer
        /// </summary>
        void RemovePrimitive(ICanvasPrimitive primitive);
    }

    #region "Exceptions"

    /// <summary>
    /// Raises this exception when the wrong type of primitive is added to a rederer
    /// </summary>
    public class InvalidPrimitiveType : CanvasManager.CanvasException
    {
        public InvalidPrimitiveType(ICanvasPrimitiveRenderer renderer, ICanvasPrimitive primitive)
            : base(Tomahawk.Runtime.Debug.Exceptions.ExceptionSeverity.Error,
            String.Format("Invalid primitive type. {0} does not support primitives of type {1}", renderer.GetType().Name, primitive.GetType().Name))
        {
        }
    }

    #endregion
}
